Skip to content

Make 2D line intersection independent of coefficient scale - #315

Open
kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-line2-intersect-scale-nov20
Open

kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-line2-intersect-scale-nov20

Conversation

@kaushikgunasekaren

Copy link
Copy Markdown

Bug

Line2.intersect() compares the raw cross-product weight to tol * eps. Scaling homogeneous coefficients therefore changes the answer: perpendicular lines can be reported as parallel after multiplying either line by a small nonzero number. Large scales also overflow in the cross product even when each coefficient is finite.

Change

Normalize the two line normals before comparing their determinant. The tolerance now measures the sine of the angle between the normals. Preserve the existing boolean result and the false result for zero-normal inputs; correct the stale point-return annotation and docstring to match that existing API. This is separate from #305, which changes point containment, not line-line intersection.

Validation

  • 43 focused regression/control cases: 11 fail before the fix; all 43 pass after it.
  • Perpendicular, oblique, parallel and coincident lines; either operand scaled independently; signed scales from 1e-200 to 1e200; operand order; near-parallel angular tolerance; zero-normal inputs; overflow warnings treated as errors in scale tests.
  • Full local suite: 609 passed, 3 skipped, 99 subtests passed (21 warnings), versus 566 passed on unchanged master.
  • Changed-file Black 23.10.0 and fatal flake8 checks pass. Whole-repository fatal lint has two pre-existing undefined-name findings in tests/test_dualquaternion.py.

AI assistance was used for investigation, implementation and tests. Validation is local Python testing only; no hardware validation is claimed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant